Post

Replies

Boosts

Views

Activity

Reply to Class hierarchy or not ?
Thanks,yes I meant the protected access modifier.Is there any solution without setters, here is just a little example I have in mind.protocol SoldierProtocol { func attack() func move()...}class Soldier: SoldierProtocol { var healthPoints: Int var attack: Int var defense: Int var type: SoldierType func attack { ... }...}class Archer: Soldier {init() { super.init() healtPoints = 100 attack = 10 defense = 2 type = .ARCHER }}let soldier: SoldierProtocol = Archer()...So I still have an internal initializer for the Soldier class, but if I dont use it and write a doc for it, it may be ok?Is this a valid alternative or should I go with setters ?
May ’20
Reply to Class hierarchy or not ?
Thanks,suppose there is another enum Country and the default value for the Soldier depends on the SoldierType and Country,I got like 50+ possible combinations, would it be good to combine both approaches,for example like this?enum Country { GERMANY FRANCE NORWAY...}class Archer: Soldier { init(country: Country) { super.init() self.country = country type = .ARCHER switch country { case .GERMANY: healtPoints = 10 attack = 10 defense = 2 ... } }}
May ’20
Reply to Class hierarchy or not ?
I do not want to my make my variables internal, but private so I need setters to provide my default values for different Soldies.when subclassing Soldier. I do not want to change any function in a subclass it is all about the default values and not having internal variables.So I wanna be able to write:let protArcher: SoldierProtocol = Archer()protArcher.move()but something like this should not be possible and is not with if I do it like above.protArcher.defense //Errorand if I dont use the protocol and put the functions in the Soldier class I could write this.If I dont use private + setters.let archer: Archer = Archer()archer.defenseMaybe Iam just unable to state what my problem is or it is not even one.Either way thanks.
May ’20
Reply to Positioning UITabBarItem's image
E.g. the "gearshape" or "gear" symbol, they are very close to the title, whereas the "function" symbol is far away. It only seems to be a few pixels, but both next to each other look pretty bad. I would upload a picture, but I don't see a way to do that here.
Feb ’21
Reply to Positioning UITabBarItem's image
First of all, thank you very much. I came across this StackOverflow question yesterday as well but thought I did something wrong and creating my own image just didn't feel right, but if that's the solution. Still, I don't understand why the imageInsets do not work on UIImages that are initialized with an SFSymbol but do work when I use an image which is in an Assets folder.
Feb ’21